cmake_minimum_required(VERSION 3.8)
project(addcustomcommand_append)

add_custom_command(OUTPUT cmd1 COMMAND echo "this is command 1")
#add_custom_command(OUTPUT cmd1 COMMAND echo "this is command 1 again")
add_custom_command(OUTPUT cmd1 COMMAND echo "this is command 1 again" APPEND)
add_custom_target(cmd1_target DEPENDS cmd1)

add_custom_command(OUTPUT cmd2 COMMAND echo "this is command 2")
add_custom_command(OUTPUT cmd3 COMMAND echo "this is command 3")
add_custom_command(OUTPUT cmd4 DEPENDS cmd2)
#add_custom_command(OUTPUT cmd4 DEPENDS cmd3)
add_custom_command(OUTPUT cmd4 DEPENDS cmd3 APPEND)
add_custom_target(cmd4_target DEPENDS cmd4)

add_custom_command(OUTPUT cmd5 COMMAND echo "this is command 5" COMMENT "this is comment 1")
add_custom_command(OUTPUT cmd5 COMMAND echo "this is command 5 again" COMMENT "this is comment 2" APPEND)
add_custom_target(cmd5_target DEPENDS cmd5)

add_custom_command(OUTPUT cmd6 COMMAND touch "1.html" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
add_custom_command(OUTPUT cmd6 COMMAND touch "2.html" WORKING_DIRECTORY ${PROJECT_BINARY_DIR} APPEND)
add_custom_command(OUTPUT cmd7 COMMAND touch "3.html" WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_custom_target(cmd6_target DEPENDS cmd6)
add_custom_target(cmd7_target DEPENDS cmd7)

add_custom_command(OUTPUT cmd8 MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/a.txt COMMAND echo "this is command 8")
add_custom_command(OUTPUT cmd8 MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/b.txt COMMAND echo "this is command 8 again" APPEND)
add_custom_target(cmd8_target DEPENDS cmd8)
